package mystia.lorelei.app.service;

import jakarta.annotation.Resource;
import mystia.lorelei.app.entity.Purchase;
import mystia.lorelei.app.repository.PurchaseRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurchaseService {
	@Resource
	private PurchaseRepository purchaseRepository;
	
	public List<Purchase> listPurchase(){return purchaseRepository.findAll();}
	public Purchase queryPurchase(int id){return purchaseRepository.findById(id).orElse(null);}
	public void savePurchase(Purchase purchase){purchaseRepository.save(purchase);}
	public void deletePurchase(int id){purchaseRepository.deleteById(id);}
	public void deletePurchases(List<Integer> ids){purchaseRepository.deleteAllByIds(ids);}
}
